package com.ruoyi.food.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ruoyi.food.mapper.TAttachMapper;
import com.ruoyi.food.mapper.TEnterpriseMapper;
import com.ruoyi.food.object.TEnterprise;
import com.ruoyi.food.service.TEnterpriseService;

@Service
@Transactional
public class TEnterpriseServiceImpl implements TEnterpriseService {

	@Autowired
	private TEnterpriseMapper tEnterpriseMapper;
	
	@Autowired
	private TAttachMapper tAttachMapper;
	
	@Override
	public List<TEnterprise> findTEnterprise(TEnterprise tEnterprise) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectTenterprise(tEnterprise);
	}

	@Override
	public List<TEnterprise> findTenterpriseByisWP(int isWaterPoint,String name) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectTenterpriseByisWP(isWaterPoint,name);
	}

	@Override
	public int saveTEnterprise(TEnterprise tEnterprise) {
		// TODO Auto-generated method stub
		int sign=1;
		tEnterpriseMapper.insetTenterprise(tEnterprise);
		return sign;
	}

	@Override
	public int updateTEnterprise(TEnterprise tEnterprise) {
		// TODO Auto-generated method stub
		int sign=1;
		tEnterpriseMapper.updateTenterprise(tEnterprise);
		return sign;
	}

	@Override
	public int deleteTenterprise(long enterpriseId) {
		// TODO Auto-generated method stub
		int sign=1;
		TEnterprise tEnterprise=tEnterpriseMapper.selectTenterpriseById(enterpriseId);
		tAttachMapper.deleteByattFkId(tEnterprise.getEnterpriseId(), "t_enterprise");
		tEnterpriseMapper.deleteTenterprise(enterpriseId);
		return sign;
	}

	@Override
	public TEnterprise findTenterpriseById(long enterpriseId) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectTenterpriseById(enterpriseId);
	}

	@Override
	public List<TEnterprise> tEnterpriseLogin(String account, String password) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectTenterpriseByPassword(account, password);
	}

	@Override
	public void updateAcOrPs(String newAccount,String newPassword, String account, String password) {
		// TODO Auto-generated method stub
		tEnterpriseMapper.updateAcOrPs(newAccount, newPassword,account, password);
		
	}

	@Override
	public List<TEnterprise> findTenterpriseBySafe(int signupSafe, String name) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectBySafe(signupSafe, name);
	}

	@Override
	public List<TEnterprise> findTenterpriseByContainType(String string) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectByContainType(string);
	}

	@Override
	public List<TEnterprise> findTenterpriseByNoContainType(String string) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectByNoContainType(string);
	}

	@Override
	public List<TEnterprise> findTenterpriseByLike(String string) {
		// TODO Auto-generated method stub
		return tEnterpriseMapper.selectByLike(string);
	}

}
